﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Provausio.Common.Utility.Extensions
{
    public static class Dictionaries
    {
        /// <summary>
        /// Converts Key/Pairs to url encoded query string
        /// </summary>
        /// <param name="value"></param>
        /// <returns>Url encoded query string</returns>
        public static string ToQueryString(this Dictionary<string, string> value)
        {
            var queryString = String.Empty;
            foreach (var pair in value)
            {
                queryString += String.Format("{0}={1}&", pair.Key, HttpUtility.UrlEncode(pair.Value));
            }
            return queryString;
        }
    }
}
